package com.sc.pattern.activeobjects;

/**
 * Created  on 2018/1/14.
 *
 * @author sc
 */
public class MakeStringThread extends Thread {

    private final ActiveObject activeObject;
    private final char fillChar;

    public MakeStringThread(ActiveObject activeObject, String name) {
        super(name);
        this.activeObject = activeObject;
        this.fillChar = name.charAt(0);
    }

    @Override
    public void run() {
        for(int i=0;true;i++){
            Result result = activeObject.makeString(i + 1, fillChar);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String resultValue = (String) result.getResultValue();
            System.out.println(Thread.currentThread().getName()+"value:"+resultValue);
        }
    }
}
